// 二维树状数组 - 区间修改 + 区间查询
#include <iostream>
using namespace std;
#define lowbit(x) (x & -x)
int n, m;
typedef long long ll;
const int N = 2050;

struct BIT
{
    ll s[N][N];
    void modify(int x, int y, ll k)
    {
        for (int i = x; i <= n; i += lowbit(i))
            for (int j = y; j <= m; j += lowbit(j))
                s[i][j] += k;
    }

    ll query(int x, int y)
    {
        ll sum = 0;
        for (int i = x; i; i -= lowbit(i))
            for (int j = y; j; j -= lowbit(j))
                sum += s[i][j];
        return sum;
    }
}A, B, C, D;

//维护d[i][j], d[i][j] * i, d[i][j] * j, d[i][j] * i * j

void add(int x, int y, ll k)
{
    A.modify(x, y, k);
    B.modify(x, y, k * x);
    C.modify(x, y, k * y);
    D.modify(x, y, k * x * y);
}

//求[1, 1]到[x, y]的和
ll sum(int x, int y)
{
    return
    A.query(x, y) * (x * y + x + y + 1) - 
    B.query(x, y) * (y + 1) - 
    C.query(x, y) * (x + 1) + 
    D.query(x, y);
}

int main()
{
    cin >> n >> m;
    int op, x1, y1, x2, y2;
    while (cin >> op >> x1 >> y1 >> x2 >> y2)
    {
        if (op == 1)
        {
            ll k; cin >> k;
            add(x1, y1, k);
            add(x1, y2 + 1, -k);
            add(x2 + 1, y1, -k);
            add(x2 + 1, y2 + 1, k);
        }
        else
        {
            cout << sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1) << endl;
        }
    }
    return 0;
}